<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>添加或编辑界面</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css"/>
    <style>
        .w440{
            width: 440px !important;
        }
    </style>
</head>
<body>
<div class="page-content-wrap clearfix">
    <form class="layui-form" id="tool">
        <div class="layui-tab">
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <input type="hidden" name="id" id="id" value="${wbDevicesType.id}" >
                    <input type="hidden" name="applyId" id="applyId" value="${wbDevicesType.applyId}" >
                    <div class="layui-form-item">
                        <label class="layui-form-label">上级分类：</label>
                        <div class="layui-input-block">
                            <input type="text" name="parentName" placeholder="" readonly value="${wbDevicesType.parentName!'主分类'}" autocomplete="off"
                                   class="layui-input">
                            <input type="hidden" name="parentId" id="parentId" value="${wbDevicesType.parentId}" >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;设备分类名称：</label>
                        <div class="layui-input-block w340">
                            <input type="text" name="name"  value ="${wbDevicesType.name}" required  lay-verify="required" placeholder="请输入场地名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;排序：</label>
                        <div class="layui-input-block w340">
                            <input type="text" name="sort" value ="${wbDevicesType.sort}"  required lay-verify="required|number" placeholder="请输入排序" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">&nbsp;备注：</label>
                        <div class="layui-input-block w340">
                            <input type="text" name="remarks" value ="${wbDevicesType.remarks}"  required  placeholder="请输入备注" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" style="margin-left: 0px !important;text-align: center">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submitBtn">提交</button>
                <button type="button" id="cancel" class="layui-btn layui-btn-primary">取消</button>
                <button type="button" style="display: none;" id="save" class="layui-btn layui-btn-primary"></button>
            </div>
        </div>
    </form>
</div>
<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['jquery', 'form', 'baseutil','dialog'], function () {
        var $ = layui.jquery,
            form = layui.form,
            baseutil = layui.baseutil,
            dialog = layui.dialog;
        //监听提交
        form.on('submit(submitBtn)', function (data) {
            data.field.id = '${wbDevicesType.id}';
            baseutil.post("/work/wb/wbdevicestype/addOrUpdate", data.field, function () {
                $("#save").click();
            });
            return false;
        });

        //监听上级菜单
        $('input[name=parentName]').bind('click', function () {
            dialog.popUpPage('选择设备分类', '/base/selector/single?url=/work/wb/wbdevicestype/dTreeList?applyId=${wxWbBulid.applyId}', '450px', '600px', function (layer, index) {
                var body = layer.getChildFrame('body', index);
                body.find("#save").bind("click", function () {
                    parent.layer.close(index);
                    var parentId = body.find("#resultId").val();
                    var parentName = body.find("#resultName").val();
                    if ('${wxWbBulid.id}' !== parentId) {
                        $('input[name=parentId]').val(parentId);
                        if (isBlank(parentId)) {
                            $('input[name=parentName]').val('主分类');
                        } else {
                            $('input[name=parentName]').val(parentName);
                        }
                    }
                });
                body.find("#cancel").bind("click", function () {
                    parent.layer.close(index);
                });
            });
        });
    });
</script>
</body>
</html>